package com.imgpro.mapper;


import com.imgpro.Enumeration.OperationType;
import com.imgpro.annotation.AutoFill;
import com.imgpro.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserMapper {

    @Select("select * from users where username = #{username}")
    User getByUsername(String username);

    @Select("select * from users where email = #{email}")
    User getByEmail(String email);

    @Select("select * from users where username = #{username} and uuid != #{uuid}")
    User getByUsernameOther(String username, String uuid);

    @Select("select * from users where email = #{email} and uuid != #{uuid}")
    User getByEmailOther(String email, String uuid);


    @AutoFill(OperationType.INSERT)
    void insert(User user);

    @Select("select * from users where uuid = #{token}")
    User getByUuid(String token);

    @AutoFill(OperationType.UPDATE)
    void updateUser(User userDTO);
}
